﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Web7.Mvc.ModelBinders
{
    public static class ValueProviderExtensions
    {
        public static string GetAttemptedValue(this IValueProvider valueProvider, string modelName)
        {
            if (string.IsNullOrWhiteSpace(modelName))
                throw new ArgumentNullException(modelName);

            ValueProviderResult result = valueProvider.GetValue(modelName);

            return result != null ? result.AttemptedValue : null;
        }
    }
}
